package com.xuxin.baby.presenter;

import com.xuxin.baby.bean.BaseBean;
import com.xuxin.baby.contract.ChildDataRecordContract;
import com.xuxin.baby.model.ChildDataRecordModel;

/**
 * Created by xu_xin
 * Created on 2020/10/22 0022
 * 记身高
 */
public class ChildDataRecordPresenter implements ChildDataRecordContract.Presenter {
    private final  ChildDataRecordModel model;
    private  final ChildDataRecordContract.View view;

    public ChildDataRecordPresenter(ChildDataRecordContract.View view) {
        this.view = view;
        model = new ChildDataRecordModel();
    }

    @Override
    public void record(String tenantId,
                       String token,
                       String eventDate,
                       String childId,
                       float height,
                       float weight,
                       float headCircle,
                       int sleepHours,
                       int sleepMinutes,
                       String eventType) {
        if (null != model) {
            model.record(this,
                    tenantId,
                    token,
                    eventDate,
                    childId,
                    height,
                    weight,
                    headCircle,
                    sleepHours,
                    sleepMinutes,
                    eventType);
        }
    }

    @Override
    public void onSuccess(BaseBean baseBean) {
        if (null != view) {
            view.onSuccess(baseBean);
        }
    }

    /**
     * 以下内容复用(用于请求完成后的操作)
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}